package qc.module.cms.mapper;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import qc.module.cms.dto.article.ArticleDto;
import qc.module.cms.dto.statistics.ArticleStatisticsByInDeptNotMergedRowResultDto;
import qc.module.cms.dto.statistics.ArticleStatisticsByInUserNotMergedRowResultDto;
import qc.module.cms.entity.Article;

import java.util.List;

/**
 * ArticleMapper
 *
 * @author QuCheng Tech
 * @since 2023/5/26
 */
@Mapper
public interface ArticleMapper {
    ArticleMapper MAPPER = Mappers.getMapper(ArticleMapper.class);

    @Mapping(target = "ctype", source = "ctype.index")
    @Mapping(target = "flag", source = "flag.index")
    @Mapping(target = "intm", source = "intm", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Mapping(target = "uptm", source = "uptm", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Mapping(target = "pubtm", source = "pubtm", dateFormat = "yyyy-MM-dd HH:mm:ss")
    ArticleDto toDto(Article en);

    List<ArticleDto> toDtoList(List<Article> list);


    //文章列表转换为按发布人统计文章未合并行结果dto
    @Mapping(target = "inUserCount", ignore = true)
    List<ArticleStatisticsByInUserNotMergedRowResultDto> toNotMergedByInUserDtoList(List<ArticleDto> list);

    //文章列表转换为按发布部门统计文章未合并行结果dto
    @Mapping(target = "inUserCount", ignore = true)
    List<ArticleStatisticsByInDeptNotMergedRowResultDto> toNotMergedByInDeptDtoList(List<ArticleDto> list);
}
